Musical Features Extractor
How to use mfeat to extract music features.In [1]:
import sys
sys.path.append("../src/mfeat/") # This is done to make the modules accessible to import
import modusa as ms
In [2]:
from high_cut_off import get_high_cutoff_freq
from loudness import get_loudness_contour
from rhythmicity import get_rhythmicity
from tempo import get_tempo
In [54]:
audio_path = "../../../music/songs/Atif Aslam, Arko - O Saathi.mp3" # Path of the audio file
local_loudness, local_loudness_t, title = get_loudness_contour(audio_path) # Computes loudness
local_cutoff, local_cutoff_t, agg_cutoff, title, S = get_high_cutoff_freq(audio_path) # Computes high cutoff freq
local_tempo, local_tempo_t, agg_tempo, confidence = get_tempo(audio_path) # Computes tempo
local_rhythmicity, local_rhythmicity_t, title = get_rhythmicity(audio_path) # Computes rhythmicity
Visualisation¶
In [55]:
display(
ms.plot1d(
(local_loudness, local_loudness_t),
title=title,
ylabel="Loudness (dB)",
xlabel="Time (sec)",
legend="Loudness contour"
)
)
display(
ms.plot2d(
(S[0], S[1], S[2]),
(local_cutoff, local_cutoff_t),
title=title,
ylabel="Frequency (Hz)",
xlabel="Time (sec)",
legend="High Cutoff"
)
)
display(
ms.plot1d(
(local_tempo, local_tempo_t),
title=title,
ylabel="Tempo (BPM)",
xlabel="Time (sec)",
legend="Tempo"
)
)
display(
ms.plot1d(
(local_rhythmicity, local_rhythmicity_t),
title=title,
ylabel="Strength",
xlabel="Time (sec)",
legend="Rhythmicity"
)
)
In [56]:
y, sr, title = ms.load(audio_path)
ms.play(y, sr)
Out[56]: